#!/usr/bin/env python
# -*- coding: utf-8 -*-

from core.utils.singleton import singleton

@singleton
class CommandManager:
    def __init__(self):
        self._cmd={}
        #self._cmdList=[]
    
    def execute(self,cmd,*arg):
        if self._cmd.has_key(cmd):
            for ind in self._cmd[cmd]:
                ind(*arg)
    
    def listener(self,cmd,callback,priority=1):
        if not self._cmd.has_key(cmd):
            self._cmd[cmd]={}
        self._cmd[cmd][callback]=priority
        
    def removeListener(self, cmd, callback=None):
        if function:
            del self._event[cmd][callback]
        else:
            del self._event[cmd]
    
    def removelistener(self):
        pass
    
    def help():
        pass